package com.example.demo.design.demo19_composite;

import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 蔡超 on 2018/10/4.
 */
public class ConcerteCompany extends Company {

    private List<Company> child = new ArrayList<Company>();

    public ConcerteCompany(String name) {
        super(name);
    }

    @Override
    void add(Company company) {
        child.add(company);
    }

    @Override
    void remove(Company company) {
        child.remove(company);

    }

    @Override
    void display() {
        System.out.println(this.getName());
        for (Company company : child) {
            company.display();
        }
    }


}
